module HplProducts.Hephaestus where
import FeatureModel.Types
import HplProducts.HephaestusTypes
import HplAssets.Hephaestus
 
data TransformationModel = UndefinedTransformation
                         | HephaestusTransformation HephaestusTransformation
 
transform ::
            TransformationModel -> SPLModel -> InstanceModel -> InstanceModel
transform (UndefinedTransformation) _ _ = undefined
transform (HephaestusTransformation x0) x1 x2
  = transformHpl  x0 x1 x2
 
mkEmptyInstance :: FeatureConfiguration -> InstanceModel
mkEmptyInstance fc
  = InstanceModel{featureConfiguration = fc, hpl = emptyHpl}
 
type ConfigurationKnowledge = [ConfigurationItem]
 
data ConfigurationItem = ConfigurationItem{expr ::
                                           FeatureExpression,
                                           transformations :: [TransformationModel]}
 
build ::
        FeatureModel ->
          FeatureConfiguration ->
            ConfigurationKnowledge -> SPLModel -> InstanceModel
build fm fc ck spl = stepRefinement ts spl emptyInstance
  where emptyInstance = mkEmptyInstance fc
        ts = tasks ck fc
 
tasks ::
        ConfigurationKnowledge ->
          FeatureConfiguration -> [TransformationModel]
tasks ck fc
  = concat [transformations c | c <- ck, eval fc (expr c)]
 
stepRefinement ::
                 [TransformationModel] -> SPLModel -> InstanceModel -> InstanceModel
stepRefinement [] splModel instanceModel = instanceModel
stepRefinement (t : ts) splModel instanceModel
  = stepRefinement ts splModel (transform t splModel instanceModel)
 
data ExportModel = UndefinedExport
                 | HephaestusExport HephaestusExport
 
export :: ExportModel -> FilePath -> InstanceModel -> IO ()
export (UndefinedExport) _ _ = undefined
export (HephaestusExport x0) x1 x2 = exportHpl  x0 x1 x2
 
lstExport :: [ExportModel]
lstExport = []